package com.example.lcpharmacy.controller;

import com.example.lcpharmacy.entity.OrderEntity;
import com.example.lcpharmacy.entity.OrderGoodsEntity;
import com.example.lcpharmacy.mapper.OrderDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderImpl {

    @Autowired
    private OrderDao orderDao;

    /**
     * 提交订单信息
     * @return
     */
    @RequestMapping("/subOrder")
    public int subOrder(@RequestBody List <OrderGoodsEntity> orderGoodsEntitys) {
        //将订单存入

        //拆单，遍历商品集合
        for (OrderGoodsEntity good: orderGoodsEntitys) {

        }
        return 0;
    }

    @RequestMapping("/getOrder")
    public List<OrderEntity> subOrder() {
        //查询订单
        List<OrderEntity> allOrder = orderDao.getAllOrder();
        return allOrder;
    }
}
